/*
2020-10-12 周一 制作
*/
#include <stdio.h>
#include <iostream>
#include <ctime>
using namespace std;
int isLeapYear(int year)
{
	if((year%4==0&&year%100!=0)||year%400==0){
	    return 1;
	}else{
		return 0;
	}
}

int getYear(){
	time_t now = time(0);
	tm *ltm = localtime(&now);
	return ltm->tm_year + 1900;
}

int getMonth(){
	time_t now = time(0);
	tm *ltm = localtime(&now);
	return ltm->tm_mon + 1;
}

int getDay(){
	time_t now = time(0);
	tm *ltm = localtime(&now);
	return ltm->tm_mday;
}

int subBtwYears(int year,int month,int day){
	int days = 0;
	int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	for(int i=1900;i<year;i++){
		if(isLeapYear(i)==1){
			days +=366;
		}else{
			days +=365;
		}
	}

	if (isLeapYear(year)==1){
		a[1] = 29;
	}
	for (int i=0;i<month-1;i++){
		days += a[i];
	}
	days = days + day;
	return days;
}

int main(){
	int birth_year,birth_month,birth_day;
	int cur_year,cur_month,cur_day;
	int livedays = 0;
	int workdays = 0;
	printf("请输入你的出生年月日(如2000-12-31):");
	scanf("%d-%d-%d",&birth_year,&birth_month,&birth_day);
	printf("你输入的生日是:%d-%d-%d\n",birth_year,birth_month,birth_day);
	cur_year = getYear();
	cur_month = getMonth();
	cur_day = getDay();
	printf("今天是:%d-%d-%d\n",cur_year,cur_month,cur_day);

	livedays = subBtwYears(cur_year,cur_month,cur_day)-subBtwYears(birth_year,birth_month,birth_day);
	workdays = subBtwYears(cur_year,cur_month,cur_day)-subBtwYears(birth_year+7,birth_month,birth_day);
	
	cout<<"你从出生到现在已经存活了"<<livedays<<"天!"<<endl;
	cout<<"你从7岁后开始已经三天打鱼两天晒网了"<<workdays<<"天!"<<endl;

	cout<<"你今天在";
	if(workdays%5==1||workdays%5==2||workdays%5==3){
		printf("打鱼!\n");
	}else{
		printf("晒网!\n");
	}
	return 0;
}
